package com.shanshan.wheel.rpc.common.registry;

import com.shanshan.wheel.rpc.common.registry.util.CuratorUtil;
import org.apache.curator.framework.CuratorFramework;
import org.springframework.stereotype.Component;

import java.net.InetSocketAddress;

/**
 * @Description zk 服务注册实现类
 * @ClassName ZkServiceRegistry
 * @Author 山山大魔王
 * @Date 2022/9/4 12:07
 * @Version 1.0
 */
@Component
public class ZkServiceRegistry implements ServiceRegistry{
    @Override
    public void registerService(String rpcServiceName, InetSocketAddress inetSocketAddress) {
        String servicePath = CuratorUtil.ZK_REGISTER_ROOT_PATH + "/" + rpcServiceName + inetSocketAddress.toString();
        CuratorFramework client = CuratorUtil.getClient();

        CuratorUtil.createPersistentNode(client, servicePath);
    }
}
